package cn.z2huo.knowledge.basic.method.variableparamlist;

import java.util.List;

/**
 * <p>
 *
 * @author z2huo
 */
class Test {

    public void stringVariableMethod(String... strings) {
        if (strings == null) {
            return;
        }
        System.out.println("length " + strings.length);
        for (String string : strings) {
            System.out.println(string);
        }
        System.out.println();
    }

    public void objectVariableMethod(Object... objects) {
        if (objects == null) {
            return;
        }
        System.out.println("length " + objects.length);
        for (Object object : objects) {
            System.out.println(object);
        }
        System.out.println();
    }

    public static void main(String[] args) {
        Test test = new Test();
        test.stringVariableMethod("1", "2", "3");

        String[] strings = new String[]{"1", "2", "3"};
        test.stringVariableMethod(strings);

        test.objectVariableMethod(List.of("1", "2", "3").stream().toArray());
        test.objectVariableMethod((Object) strings);
        test.objectVariableMethod((Object[]) strings);
    }

}
